//
//  CoinRegularModel.swift
//  Exchange
//
//  Created by 孟祥群 on 2018/7/9.
//  Copyright © 2018年 common. All rights reserved.
//

import UIKit
import ObjectMapper
class CoinRegularModel: BaseModel, Mappable {
    var id:Int?
    var openTime:String = ""
    var stepSize:Double = 0.00 //数量尺寸
    var minPrice:Double = 0.00 //委托单最低价
    var quoteLeverageLimit:Double = 0.00 //计价货币杠杆限额
    var baseLeverageLimit:Double = 0.00 //交易杠杆限额
    var decimalPlaces:Int = 0 //小数位数
    var merge:Double = 0.00
    var minQty:Double = 0.00 //最小量
    var tickSize:Double = 0.00 //价格尺寸
    var leverageTimes:String = "" //杠杆倍数
    var increase:Double = 0.0
    var checkStr:String = ""
    var closeTime:String = ""
    var sort:Int = 0
    var tradeStatus:Int = 1 //状态锁 1锁 0 没锁可用 第一级
    var maxPrice:Double = 0.00 //委托最高价
    var createTime:String = ""
    var maxQty:Double = 0.00 //最大量
    var tradeCode:String = ""
    
    var numberdigit:Int = 8 //数量支持的位数
    var priceDigit:Int = 8 //单价支持的位数
    
    var conventionLock:Int = 1 // 1锁 0 没锁可用 币币锁
    var leverageLock:Int = 1 // 1锁 0 没锁可用 杠杆锁

    var limitLock:Int = 1 //1锁 0没锁 限价锁
    var marketLock:Int = 1 //1锁 0 没锁  市价锁
    
    
    
    required init?(map: Map){}
    override init(){
        super.init()
    }
    
    func mapping(map: Map)
    {
        baseLeverageLimit <- map["baseLeverageLimit"]
        closeTime <- map["closeTime"]
        createTime <- map["createTime"]
        decimalPlaces <- map["decimalPlaces"]
        id <- map["id"]
        increase <- map["increase"]
        maxPrice <- map["maxPrice"]
        maxQty <- map["maxQty"]
        minPrice <- map["minPrice"]
        minQty <- map["minQty"]
        openTime <- map["openTime"]
        quoteLeverageLimit <- map["quoteLeverageLimit"]
        sort <- map["sort"]
        stepSize <- map["stepSize"]
        tickSize <- map["tickSize"]
        tradeStatus <- map["tradeStatus"]
        leverageTimes <- map["leverageTimes"]
        tradeCode <- map["tradeCode"]
        conventionLock <- map["conventionLock"]
        leverageLock <- map["leverageLock"]
        limitLock <- map["limitLock"]
        marketLock <- map["marketLock"]
        
        self.archiveNumberDigit()
        self.archivePriceDigit()
    }
    
    func archiveNumberDigit()  {
        let number = CYCalculate.cy_intercept(number: stepSize, digit: 8)
        if (number?.contains("."))! {
            let array = number?.components(separatedBy: ".").last
            numberdigit = (array?.count)!
        }else {
            numberdigit = 0
        }
    }
    
    func archivePriceDigit() {
        let number = CYCalculate.cy_intercept(number: tickSize, digit: 8)
        if (number?.contains("."))! {
            let array = number?.components(separatedBy: ".").last
            priceDigit = (array?.count)!
        }else {
            priceDigit = 0
        }
    }
}
